package com.serkol.ams.modal;

import com.serkol.constant.AuthConstant;
import com.serkol.utils.LangValidUtils;

public class SqlFeildModal {

    public static String getAgentFeild() {

        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");
        if (LangValidUtils.getValid("ug")) {
            sb.append("IFNULL(NAME_UG,NAME) as name,");
        } else {
            sb.append("NAME as name,");
        }
        sb.append("NAME as nameOther,");
        sb.append("PRICE as price,");
        sb.append("LEVEL as level,");
        sb.append("SORT as sort,");
        sb.append("STATE as state");
        return sb.toString();

    }

    public static String getAgentSelectFeild() {

        StringBuilder sb = new StringBuilder();
        sb.append("ID as value,");

        sb.append("NAME as label");

        return sb.toString();
    }

    public static String getAgentSelectTypeFeild() {

        StringBuilder sb = new StringBuilder();
        sb.append("ID as value,");

        sb.append("NAME as text");

        return sb.toString();
    }


    public static String getUsersFeild() {

        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");

        sb.append("NICKNAME as nickname,");


        sb.append("AVATAR as avatar,");
        sb.append("STATUS as status,");
        sb.append("USER_NAME as userName,");
        sb.append("PHONE as phone,");
        sb.append("AGENT_ID as agentId,");
        sb.append("CREATE_DATE as createDate,");
        // sb.append("(SELECT NAME FROM users_authentication WHERE USER_ID=x.ID LIMIT 1) AS name,");
        //  sb.append("(SELECT BALANCE FROM users_wallet where user_id=x.ID LIMIT 1) AS balance,");
        //   sb.append("(SELECT SUM(PRICE) FROM users_wallet_log where user_id=x.ID AND STATE=1 LIMIT 1) AS monthPrice,");
        sb.append("(SELECT "+LangValidUtils.getValid("ug","IFNULL(NAME_UG,NAME)","NAME")+" FROM users_authentication as tusers_authentication WHERE USER_ID=x.PARENT_USER_ID LIMIT 1) AS parentName,");
          sb.append("(SELECT "+LangValidUtils.getValid("ug","NAME_UG","NAME")+" FROM agent as tagent WHERE ID=x.AGENT_ID LIMIT 1) AS agentName,");
        sb.append("(SELECT "+LangValidUtils.getValid("ug","IFNULL(NAME_UG,NAME)","NAME")+" FROM users_authentication as tusers_authentication WHERE USER_ID=x.ID LIMIT 1) AS authName");

        return sb.toString();

    }

    public static String getUsersFullFeild() {

        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");

        sb.append("NICKNAME as nickname,");

        sb.append("AVATAR as avatar,");
        sb.append("USER_NAME as userName,");
        sb.append("INVITE as invite,");
        sb.append("PHONE as phone,");
        sb.append("OPENID as openId,");
        sb.append("CREATE_DATE as createDate,");

        sb.append("AGENT_STATE as agentState,");
        sb.append("STATUS as status,");
        sb.append("AGENT_ID as agentId,");

        sb.append("(SELECT BALANCE FROM users_wallet as tusers_wallet where user_id=x.ID LIMIT 1) AS balance,");
        sb.append("(SELECT SUM(REQUEST_AMOUNT) FROM users_wallet_withdrawal as tusers_wallet_withdrawal WHERE USER_ID =x.ID  AND STATUS=1   LIMIT 1) AS withdrawal,");
        sb.append("(SELECT SUM(REQUEST_AMOUNT) FROM users_wallet_withdrawal as tusers_wallet_withdrawal WHERE USER_ID =x.ID AND STATUS=2  LIMIT 1) AS withdrawalWait,");
        sb.append("(SELECT COUNT(*) FROM users_wallet_withdrawal as tusers_wallet_withdrawal WHERE USER_ID =x.ID AND STATUS=1  LIMIT 1) AS withdrawaCount,");
        sb.append("(SELECT WECHAT FROM users_authentication as tusers_authentication WHERE USER_ID=x.ID LIMIT 1) AS wechat,");
        sb.append("(SELECT IDCARD FROM users_authentication as tusers_authentication  WHERE USER_ID=x.ID LIMIT 1) AS idCard,");
        sb.append("(SELECT ADDRESS FROM users_authentication as tusers_authentication  WHERE USER_ID=x.ID LIMIT 1) AS address,");
   /*     sb.append("(SELECT BANK_NAME FROM users_authentication WHERE USER_ID=users.ID LIMIT 1) AS bankName,");
       sb.append("(SELECT NAME FROM users_authentication WHERE USER_ID=users.ID LIMIT 1) AS name,");
        sb.append("(SELECT BANK_ADDRESS FROM users_authentication WHERE USER_ID=users.ID LIMIT 1) AS bankAddress,");
        sb.append("(SELECT BANK_CARD FROM users_authentication WHERE USER_ID=users.ID LIMIT 1) AS bankCard,");*/
        sb.append("(SELECT NAME FROM users_authentication as tusers_authentication  WHERE USER_ID=x.PARENT_USER_ID LIMIT 1) AS parentName,");
        sb.append("(SELECT PHONE FROM users_authentication as tusers_authentication  WHERE USER_ID=x.PARENT_USER_ID LIMIT 1) AS parentPhone,");
        if (LangValidUtils.getValid("ug")) {
            sb.append("(SELECT IFNULL(NAME_UG,NAME) FROM users_authentication as tusers_authentication  WHERE USER_ID=x.ID LIMIT 1) AS name,");
            sb.append("(SELECT IFNULL(NAME_UG,NAME) FROM agent as tagent WHERE ID=x.AGENT_ID LIMIT 1) AS agentName");
        } else {
            sb.append("(SELECT NAME FROM users_authentication as tusers_authentication  WHERE USER_ID=x.ID LIMIT 1) AS name,");
            sb.append("(SELECT NAME FROM agent as tagent WHERE ID=x.AGENT_ID LIMIT 1) AS agentName");
        }

        return sb.toString();

    }


    public static String getUsersFullSourceFeild() {

        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");

        sb.append("NICKNAME as nickname,");

        sb.append("AVATAR as avatar,");
        sb.append("USER_NAME as userName,");
        sb.append("INVITE as invite,");
        sb.append("PHONE as phone,");
        sb.append("OPENID as openId,");
        sb.append("CREATE_DATE as createDate,");

        sb.append("AGENT_STATE as agentState,");
        sb.append("STATUS as status,");

        sb.append("(SELECT BALANCE FROM users_wallet as tusers_wallet where user_id=x.ID LIMIT 1) AS balance,");
        sb.append("(SELECT SUM(REQUEST_AMOUNT) FROM users_wallet_withdrawal as tusers_wallet_withdrawal WHERE USER_ID =x.ID  AND STATUS=1   LIMIT 1) AS withdrawal,");
        sb.append("(SELECT SUM(REQUEST_AMOUNT) FROM users_wallet_withdrawal as tusers_wallet_withdrawal WHERE USER_ID =x.ID AND STATUS=2  LIMIT 1) AS withdrawalWait,");
        sb.append("(SELECT COUNT(*) FROM users_wallet_withdrawal as tusers_wallet_withdrawal WHERE USER_ID =x.ID AND STATUS=1  LIMIT 1) AS withdrawaCount,");
        sb.append("(SELECT WECHAT FROM users_authentication as tusers_authentication  WHERE USER_ID=x.ID LIMIT 1) AS wechat,");
        sb.append("(SELECT IDCARD FROM users_authentication as tusers_authentication  WHERE USER_ID=x.ID LIMIT 1) AS idCard,");
        sb.append("(SELECT ADDRESS FROM users_authentication as tusers_authentication  WHERE USER_ID=x.ID LIMIT 1) AS address,");
        sb.append("(SELECT BANK_NAME FROM users_authentication as tusers_authentication  WHERE USER_ID=x.ID LIMIT 1) AS bankName,");
        sb.append("(SELECT BANK_ADDRESS FROM users_authentication as tusers_authentication  WHERE USER_ID=x.ID LIMIT 1) AS bankAddress,");
        sb.append("(SELECT BANK_CARD FROM users_authentication as tusers_authentication  WHERE USER_ID=x.ID LIMIT 1) AS bankCard,");
        sb.append("(SELECT NAME FROM users_authentication as tusers_authentication  WHERE USER_ID=x.PARENT_USER_ID LIMIT 1) AS parentName,");
        sb.append("(SELECT PHONE FROM users_authentication as tusers_authentication  WHERE USER_ID=x.PARENT_USER_ID LIMIT 1) AS parentPhone,");

        sb.append("(SELECT NAME FROM users_authentication as tusers_authentication WHERE USER_ID=x.ID LIMIT 1) AS name,");
        sb.append("(SELECT NAME FROM agent WHERE ID=x.AGENT_ID LIMIT 1) AS agentName");


        return sb.toString();

    }

    public static String getUsersAgentFullFeild() {

        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");

        sb.append("NICKNAME as nickname,");

        sb.append("AVATAR as avatar,");
        sb.append("USER_NAME as userName,");
        sb.append("INVITE as invite,");
        sb.append("PHONE as phone,");
        sb.append("CREATE_DATE as createDate,");
        sb.append("(SELECT NAME FROM users_authentication as tusers_authentication WHERE USER_ID=x.ID LIMIT 1) AS name,");
        sb.append("(SELECT COUNT(*) FROM users as tusers  WHERE PARENT_USER_ID=x.ID LIMIT 1) AS agentCount,");
        sb.append("(SELECT WECHAT FROM users_authentication as tusers_authentication WHERE USER_ID=x.ID LIMIT 1) AS wechat,");
        sb.append("(SELECT NAME FROM users_authentication as tusers_authentication WHERE USER_ID=x.PARENT_USER_ID LIMIT 1) AS parentName,");
        sb.append("(SELECT NAME FROM agent as tagent WHERE ID=x.AGENT_ID LIMIT 1) AS agentName");

        return sb.toString();

    }


    public static String getUsersWalletFullFeild() {

        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");

        sb.append("NICKNAME as nickname,");

        sb.append("AVATAR as avatar,");
        sb.append("USER_NAME as userName,");
        sb.append("INVITE as invite,");
        sb.append("PHONE as phone,");
        sb.append("AGENT_ID as agentId,");
        sb.append("CREATE_DATE as createDate,");
        sb.append("(SELECT BALANCE FROM users_wallet where user_id=x.ID LIMIT 1) AS balance,");
        sb.append("(SELECT INTEGRAL FROM users_wallet where user_id=x.ID LIMIT 1) AS integral,");
        sb.append("(SELECT NAME FROM users_authentication WHERE USER_ID=x.ID LIMIT 1) AS name,");
        sb.append("(SELECT COUNT(*) FROM users  WHERE PARENT_USER_ID=x.ID LIMIT 1) AS agentCount,");
        sb.append("(SELECT WECHAT FROM users_authentication WHERE USER_ID=x.ID LIMIT 1) AS wechat,");
        sb.append("(SELECT NAME FROM users_authentication WHERE USER_ID=x.PARENT_USER_ID LIMIT 1) AS parentName");
        //  sb.append("(SELECT NAME FROM agent WHERE ID=x.AGENT_ID LIMIT 1) AS agentName");

        return sb.toString();

    }

    public static String getCurrentUser() {
        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");

        sb.append("NICKNAME as nickName,");
        sb.append("AVATAR as avatarUrl,");
        sb.append("AVATAR as avatar,");
        sb.append("USER_NAME as userName,");
        sb.append("USER_NAME as name,");
        sb.append("PHONE as phone,");
        sb.append("ROLE_ID as roleId,");
        sb.append("IS_ADMIN as isAdmin,");
        sb.append("CREATE_DATE as createDate,");
        sb.append("(SELECT NICKNAME FROM users WHERE ID=x.PARENT_USER_ID LIMIT 1) AS parentName,");
        sb.append("(SELECT NAME FROM agent WHERE ID=x.AGENT_ID LIMIT 1) AS agentName");

        return sb.toString();
    }

    public static String getTreeUser() {
        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");

        sb.append("NICKNAME as nickName,");


        sb.append("AVATAR as avatar,");
        sb.append("PHONE as phone,");
        sb.append("PARENT_USER_ID as parentUserId,");

        if (LangValidUtils.getValid("ug")) {
            sb.append("(SELECT IF(NAME_UG,NAME_UG,NAME) FROM users_authentication WHERE USER_ID=x.ID LIMIT 1) AS name,");
        } else {
            sb.append("(SELECT NAME FROM users_authentication WHERE USER_ID=x.ID LIMIT 1) AS name,");
        }

        sb.append("(SELECT NAME FROM agent WHERE ID=x.AGENT_ID LIMIT 1) AS agentName");

        return sb.toString();
    }

    public static String getAgentUserFeild(long userId) {

        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");
        if (LangValidUtils.getValid("ug")) {
            sb.append("IFNULL(NAME_UG,NAME) as name,");
        } else {
            sb.append("NAME as name,");
        }
        sb.append("(SELECT count(*) FROM users as c WHERE AGENT_ID=x.ID AND  PARENT_USER_ID=" + userId + ") as count,");
        sb.append("PRICE as price,");
        sb.append("LEVEL as level,");
        sb.append("SORT as sort");
        return sb.toString();

    }

    public static String getCategoryFeild() {

        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");
        if (LangValidUtils.getValid("ug")) {
            sb.append("IFNULL(NAME_UG,NAME) as name,");
        } else {
            sb.append("NAME as name,");
        }
        sb.append("SORT as sort");
        return sb.toString();
    }

    public static String getCategorySelectFeild() {

        StringBuilder sb = new StringBuilder();
        sb.append("ID as value,");

        sb.append("NAME as label,");

        sb.append("SORT as sort");
        return sb.toString();
    }

    public static String getGoodsSelectFeild() {
        StringBuilder sb = new StringBuilder();
        sb.append("ID as value,");

        sb.append("NAME as label");

        return sb.toString();
    }

    public static String getCategoryListFeild() {

        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");

        sb.append("IFNULL(NAME_UG,NAME) as nameUg,");

        sb.append("NAME as name,");
        sb.append(getPicture("IMAGE_ID") + " as image,");

        sb.append("SORT as sort");
        return sb.toString();
    }

    public static String getGoodsFeild(long id) {
        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");

        if (LangValidUtils.getValid("ug")) {
            sb.append("IFNULL(NAME_UG,NAME) as name,");
            sb.append("REMARK_UG as remark,");
            sb.append("CONTENT as content,");
        } else {
            sb.append("NAME as name,");
            sb.append("REMARK as remark,");
            sb.append("CONTENT as content,");
        }
        System.out.println("LLLLLLLLLLLL" + id);
        if (id > 0) {
            sb.append("(SELECT PRICE FROM  good_agent_price as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + id + ")  LIMIT 1) as price ,");
        } else {
            sb.append("MARKET_PRICE as price,");
        }
        sb.append(getPicture("IMAGE_ID") + " as image,");
        sb.append("BRAND_ID as brandId,");
        sb.append("CATEGORY_ID as categoryId,");
        sb.append("(SELECT NAME FROM category WHERE ID=x.CATEGORY_ID LIMIT 1) AS categoryName,");
        sb.append("QUANTITY as quantity,");
        sb.append("MEASURE as measure,");
        sb.append("PERMIT as permit,");
        sb.append("WEIGHT as weight,");
        sb.append("LINKS as links,");
        sb.append("PUBLISH_TIME as publishTime,");
        sb.append("GOOD_NUMBER as goodNumber,");
        sb.append("INVENTORY as inventory,");
        sb.append("SIZE as size,");
        sb.append("COLORS as colors,");
        sb.append("MARKET_PRICE as marketPrice,");
        sb.append("RETAIL_PRICE as retailPrice,");
        sb.append("IMAGE_ID as imageId,");
        sb.append("IMAGE_IDS as imageIds,");
        sb.append(getPictures("IMAGE_IDS") + " as images,");

        sb.append("VIDEO_ID as videoId,");
        sb.append(getPicture("VIDEO_ID") + " as video,");
        sb.append("CREATE_DATE as createDate,");
        sb.append("UPDATE_DATE as updateDate");
        return sb.toString();
    }

    public static String getGoodsBackFeild(long id) {
        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");


        sb.append("IFNULL(NAME_UG,NAME) as nameUg,");
        sb.append("REMARK_UG as remarkUg,");
        sb.append("CONTENT_UG as contentUg,");

        sb.append("NAME as name,");
        sb.append("REMARK as remark,");
        sb.append("CONTENT as content,");

        if (id > 0) {
            sb.append("(SELECT PRICE FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + id + ")  LIMIT 1) as price ,");
        } else {
            sb.append("MARKET_PRICE as price,");
        }
        sb.append(getPicture("IMAGE_ID") + " as image,");
        sb.append("BRAND_ID as brandId,");
        sb.append("CATEGORY_ID as categoryId,");
        sb.append("(SELECT NAME FROM category WHERE ID=x.CATEGORY_ID LIMIT 1) AS categoryName,");
        sb.append("QUANTITY as quantity,");
        sb.append("MEASURE as measure,");
        sb.append("PERMIT as permit,");
        sb.append("WEIGHT as weight,");
        sb.append("LINKS as links,");
        sb.append("PUBLISH_TIME as publishTime,");
        sb.append("GOOD_NUMBER as goodNumber,");
        sb.append("INVENTORY as inventory,");
        sb.append("SIZE as size,");
        sb.append("COLORS as colors,");
        sb.append("MARKET_PRICE as marketPrice,");
        sb.append("RETAIL_PRICE as retailPrice,");
        sb.append("IMAGE_ID as imageId,");
        sb.append("IMAGE_IDS as imageIds,");
        sb.append(getPictures("IMAGE_IDS") + " as images,");

        sb.append("VIDEO_ID as videoId,");
        sb.append(getPicture("VIDEO_ID") + " as video,");
        sb.append("CREATE_DATE as createDate,");
        sb.append("UPDATE_DATE as updateDate");
        return sb.toString();
    }

    public static String getGoodsNewListFeild(long agentId) {
        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");

        if (LangValidUtils.getValid("ug")) {
            sb.append("IFNULL(NAME_UG,NAME) as name,");

        } else {
            sb.append("NAME as name,");
        }
        if (agentId > 0) {
            //   sb.append("(SELECT NEW_PRICE FROM `good_agent_price` WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1) as price ,");
           sb.append("(SELECT IF(x.IS_ACTIVTY=1,ACTIVE_PRICE,NEW_PRICE) PRICE FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1) as price ,");
         //   sb.append("(SELECT  PRICE FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1) as price ,");

        }
        sb.append(getPicture("IMAGE_ID") + " as image,");
        sb.append("MARKET_PRICE as marketPrice,");
        sb.append("BRAND_ID as brandId,");
        sb.append("CATEGORY_ID as categoryId,");
        sb.append("IS_ACTIVTY as isActivty,");
        sb.append("QUANTITY as quantity");

        return sb.toString();
    }
    public static String getGoodsNewListShopFeild(long agentId) {
        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");

        if (LangValidUtils.getValid("ug")) {
            sb.append("IFNULL(NAME_UG,NAME) as name,");

        } else {
            sb.append("NAME as name,");
        }
        if (agentId > 0) {
            //   sb.append("(SELECT NEW_PRICE FROM `good_agent_price` WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1) as price ,");
          //  sb.append("(SELECT IF(x.IS_ACTIVTY=1,ACTIVE_PRICE,NEW_PRICE) PRICE FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1) as price ,");
               sb.append("(SELECT  PRICE FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1) as price ,");

        }
        sb.append(getPicture("IMAGE_ID") + " as image,");
        sb.append("MARKET_PRICE as marketPrice,");
        sb.append("BRAND_ID as brandId,");
        sb.append("CATEGORY_ID as categoryId,");
        sb.append("IS_ACTIVTY as isActivty,");
        sb.append("QUANTITY as quantity");

        return sb.toString();
    }

    public static String getGoodsBackNewListFeild(long agentId) {
        StringBuilder sb = new StringBuilder();


        sb.append("ID as goodsId,");

        if (LangValidUtils.getValid("ug")) {
            sb.append("IFNULL(NAME_UG,NAME) as name,");

        } else {
            sb.append("NAME as name,");
        }
        if (agentId > 0) {
            //   sb.append("(SELECT NEW_PRICE FROM `good_agent_price` WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1) as price ,");
            sb.append("(SELECT NEW_PRICE  FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1) as paymentAmount ,");
            sb.append("(SELECT NEW_PRICE  FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1) as paymentAmountL ,");
            sb.append("(SELECT NEW_PRICE  FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1) as price ,");

        }
        sb.append(getPicture("IMAGE_ID") + " as image,");
        sb.append("MARKET_PRICE as totalAmount,");
        sb.append("MARKET_PRICE as totalAmountL,");
        sb.append("MARKET_PRICE-(SELECT NEW_PRICE  FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1)  as discountAmount,");
        sb.append("MARKET_PRICE-(SELECT NEW_PRICE  FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1)  as discountAmountL,");
        sb.append("BRAND_ID as brandId,");
        sb.append("CATEGORY_ID as categoryId,");
        sb.append(" 1  as quantity,");
        sb.append("0 as totalAmount");
/*        sb.append("MEASURE as measure");
        sb.append("PERMIT as permit");
        sb.append("WEIGHT as weight");
        sb.append("LINKS as links");
        sb.append("PUBLISH_TIME as publishTime");ams
        sb.append("GOOD_NUMBER as goodNumber");
        sb.append("INVENTORY as inventory");
        sb.append("SIZE as size");
        sb.append("COLORS as colors");
        sb.append("MARKET_PRICE as marketPrice");
        sb.append("RETAIL_PRICE as retailPrice");
        sb.append("IMAGE_ID as imageId");
        sb.append("IMAGE_IDS as imageIds");
        sb.append("VIDEO_ID as videoId");
        sb.append("CREATE_DATE as createDate");
        sb.append("UPDATE_DATE as updateDate");*/
        return sb.toString();
    }

    public static String getGoodsTaoCanNewListFeild(Long taocanId, long agentId) {
        StringBuilder sb = new StringBuilder();
        sb.append("(SELECT  ID FROM  taocan_detail as ttaocan_detail where GOODS_ID=x.ID AND TAOCAN_ID=" + taocanId + " LIMIT 1) as id,");
        sb.append(taocanId + " as taocanId,");

        sb.append("ID as goodsId,");

        if (LangValidUtils.getValid("ug")) {
            sb.append("IFNULL(NAME_UG,NAME) as name,");

        } else {
            sb.append("NAME as name,");
        }
        if (agentId > 0) {
            //   sb.append("(SELECT NEW_PRICE FROM `good_agent_price` WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1) as price ,");
            sb.append("(SELECT  NEW_PRICE FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1) as paymentAmount ,");
            sb.append("(SELECT  NEW_PRICE FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1) as paymentAmountL ,");
            sb.append("(SELECT  NEW_PRICE FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1) as price ,");

        }
        sb.append(getPicture("IMAGE_ID") + " as image,");
        sb.append("MARKET_PRICE as totalAmount,");
        sb.append("MARKET_PRICE as totalAmountL,");
        sb.append("MARKET_PRICE-(SELECT  NEW_PRICE FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1)  as discountAmount,");
        sb.append("MARKET_PRICE-(SELECT  NEW_PRICE FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1)  as discountAmountL,");
        sb.append("BRAND_ID as brandId,");
        sb.append("CATEGORY_ID as categoryId,");
        sb.append("(SELECT  QUANTITY  FROM  taocan_detail as ttaocan_detail where GOODS_ID=x.ID  AND TAOCAN_ID=" + taocanId + "  LIMIT 1) as quantity");
/*        sb.append("MEASURE as measure");
        sb.append("PERMIT as permit");
        sb.append("WEIGHT as weight");
        sb.append("LINKS as links");
        sb.append("PUBLISH_TIME as publishTime");ams
        sb.append("GOOD_NUMBER as goodNumber");
        sb.append("INVENTORY as inventory");
        sb.append("SIZE as size");
        sb.append("COLORS as colors");
        sb.append("MARKET_PRICE as marketPrice");
        sb.append("RETAIL_PRICE as retailPrice");
        sb.append("IMAGE_ID as imageId");
        sb.append("IMAGE_IDS as imageIds");
        sb.append("VIDEO_ID as videoId");
        sb.append("CREATE_DATE as createDate");
        sb.append("UPDATE_DATE as updateDate");*/
        return sb.toString();
    }

    public static String getGoodsHomeListFeild(long agentId) {
        System.out.println("Login1");
        System.out.println(agentId);
        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");

        if (LangValidUtils.getValid("ug")) {
            sb.append("IFNULL(NAME_UG,NAME) as name,");

        } else {
            sb.append("NAME as name,");
        }
        if (agentId > 0) {
            sb.append("(SELECT IF(x.IS_ACTIVTY=1,ACTIVE_PRICE,PRICE) PRICE FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1) as price ,");
        } else {
            sb.append("MARKET_PRICE as price,");
        }
        sb.append(getPicture("IMAGE_ID") + " as image,");
        sb.append("MARKET_PRICE as marketPrice,");
        sb.append("BRAND_ID as brandId,");
        sb.append("IS_ACTIVTY as isActivty,");
        sb.append("CATEGORY_ID as categoryId,");
        sb.append("QUANTITY as quantity");
/*        sb.append("MEASURE as measure");
        sb.append("PERMIT as permit");
        sb.append("WEIGHT as weight");
        sb.append("LINKS as links");
        sb.append("PUBLISH_TIME as publishTime");ams
        sb.append("GOOD_NUMBER as goodNumber");
        sb.append("INVENTORY as inventory");
        sb.append("SIZE as size");
        sb.append("COLORS as colors");
        sb.append("MARKET_PRICE as marketPrice");
        sb.append("RETAIL_PRICE as retailPrice");
        sb.append("IMAGE_ID as imageId");
        sb.append("IMAGE_IDS as imageIds");
        sb.append("VIDEO_ID as videoId");
        sb.append("CREATE_DATE as createDate");
        sb.append("UPDATE_DATE as updateDate");*/
        return sb.toString();
    }


    public static String getGoodsPosterFeild() {
        System.out.println("Login1");

        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");


        sb.append("NAME as name,");


        sb.append("MARKET_PRICE as price,");

        sb.append(getPicture("IMAGE_ID") + " as image,");
        sb.append("MARKET_PRICE as marketPrice,");

        sb.append("QUANTITY as quantity");
/*        sb.append("MEASURE as measure");
        sb.append("PERMIT as permit");
        sb.append("WEIGHT as weight");
        sb.append("LINKS as links");
        sb.append("PUBLISH_TIME as publishTime");ams
        sb.append("GOOD_NUMBER as goodNumber");
        sb.append("INVENTORY as inventory");
        sb.append("SIZE as size");
        sb.append("COLORS as colors");
        sb.append("MARKET_PRICE as marketPrice");
        sb.append("RETAIL_PRICE as retailPrice");
        sb.append("IMAGE_ID as imageId");
        sb.append("IMAGE_IDS as imageIds");
        sb.append("VIDEO_ID as videoId");
        sb.append("CREATE_DATE as createDate");
        sb.append("UPDATE_DATE as updateDate");*/
        return sb.toString();
    }

    public static String getGoodsBackListFeild() {
        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");


        sb.append("NAME_UG as nameUg,");


        sb.append("NAME as name,");


        sb.append(getPicture("IMAGE_ID") + " as image,");
        sb.append("MARKET_PRICE as marketPrice,");
        sb.append("BRAND_ID as brandId,");
        sb.append("CATEGORY_ID as categoryId,");
        sb.append("QUANTITY as quantity,");
        sb.append("MEASURE as measure,");
        sb.append("PERMIT as permit,");
        sb.append("WEIGHT as weight,");
        sb.append("LINKS as links,");
        sb.append("PUBLISH_TIME as publishTime,");
        sb.append("GOOD_NUMBER as goodNumber,");
        sb.append("INVENTORY as inventory,");
        sb.append("SIZE as size,");
        sb.append("COLORS as colors,");
        sb.append("MARKET_PRICE as marketPrice,");
        sb.append("RETAIL_PRICE as retailPrice,");
        sb.append("IMAGE_ID as imageId,");
        sb.append("IMAGE_IDS as imageIds,");
        sb.append("VIDEO_ID as videoId,");
        sb.append("CREATE_DATE as createDate,");
        sb.append("UPDATE_DATE as updateDate,");
        sb.append("(SELECT NAME FROM category WHERE ID=x.CATEGORY_ID LIMIT 1) AS categoryName");
        return sb.toString();
    }

    public static String getGoodsBackCloudFeild() {
        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");


        sb.append("NAME_UG as nameUg,");


        sb.append("NAME as name,");


        sb.append(getPicture("IMAGE_ID") + " as image,");
        sb.append("MARKET_PRICE as marketPrice,");
        sb.append("BRAND_ID as brandId,");
        sb.append("CLOUD_TYPE as cloudType,");

        sb.append("CATEGORY_ID as categoryId,");
        sb.append(getCloudGoods("x.ID") + " as quantity,");
        sb.append("MEASURE as measure,");
        sb.append("PERMIT as permit,");
        sb.append("WEIGHT as weight,");
        sb.append("LINKS as links,");
        sb.append("PUBLISH_TIME as publishTime,");
        sb.append("GOOD_NUMBER as goodNumber,");
        sb.append("INVENTORY as inventory,");
        sb.append("SIZE as size,");
        sb.append("COLORS as colors,");
        sb.append("MARKET_PRICE as marketPrice,");
        sb.append("RETAIL_PRICE as retailPrice,");
        sb.append("IMAGE_ID as imageId,");
        sb.append("IMAGE_IDS as imageIds,");
        sb.append("VIDEO_ID as videoId,");
        sb.append("CREATE_DATE as createDate,");
        sb.append("UPDATE_DATE as updateDate,");
        sb.append("(SELECT NAME FROM category WHERE ID=x.CATEGORY_ID LIMIT 1) AS categoryName");
        return sb.toString();
    }


    public static String getGoodsBackIntegralListFeild() {
        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");


        sb.append("NAME_UG as nameUg,");


        sb.append("NAME as name,");


        sb.append(getPicture("IMAGE_ID") + " as image,");

        sb.append("QUANTITY as quantity,");
        sb.append("INTEGRAL as integral,");


        sb.append("CREATE_DATE as createDate,");
        sb.append("UPDATE_DATE as updateDate,");
        sb.append("(SELECT NAME FROM category WHERE ID=x.CATEGORY_ID LIMIT 1) AS categoryName");
        return sb.toString();
    }

    public static String getOrderFeild() {
        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");
        sb.append("USER_ID as userId,");
        sb.append("OPERATOR_ID as operatorId,");

        sb.append(getAuthName("x.USER_ID") + " as userName,");
        sb.append(getAuthName("OPERATOR_ID") + " as operatorName,");

        sb.append(getUserAddress("x.ADDRESS_ID") + " as address,");
        sb.append(getUserAddressPhoneNumber("x.ADDRESS_ID") + " as phone,");

        sb.append("ADDRESS_ID as addressId,");
        sb.append("SN as sn,");
        sb.append("PARTY_SN as partySn,");
        sb.append("PARTY_ID as partyId,");
        sb.append("CATEGORY_ID as categoryId,");
        sb.append("PAYMENT_METHOD as paymentMethod,");
        sb.append("PAYMENT_STATUS as paymentStatus,");
        sb.append("PAYMENT_DATE as paymentDate,");
        sb.append("PAYMENT_AMOUNT as paymentAmount,");
        sb.append("DISCOUNT_AMOUNT as discountAmount,");
        sb.append("TOTAL_AMOUNT as totalAmount,");
        sb.append("STATUS as status,");
        sb.append("IS_PAY as isPay,");
        sb.append("CLOUD_TYPE as cloudType,");

        sb.append("CREATE_DATE as createDate,");
        sb.append("UPDATE_DATE as updateDate,");

        sb.append("QUANTITY as quantity");


        return sb.toString();
    }

    public static String getOrderDetailFeild() {
        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");
        sb.append("USER_ID as userId,");


        sb.append(getAuthName("USER_ID") + " as userName,");
        sb.append(goodsName("x.GOODS_ID") + " as goodsName,");
        sb.append(goodsImage("x.GOODS_ID") + " as image,");


        sb.append("PAYMENT_AMOUNT as paymentAmount,");
        sb.append("DISCOUNT_AMOUNT as discountAmount,");
        sb.append("TOTAL_AMOUNT as totalAmount,");
        sb.append("STATUS as status,");


        sb.append("CREATE_DATE as createDate,");
        sb.append("UPDATE_DATE as updateDate,");

        sb.append("QUANTITY as quantity,");
        sb.append("PRICE as price");


        return sb.toString();
    }

    public static String getOrderCloudFeild() {
        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");
        sb.append("USER_ID as userId,");
        sb.append("OPERATOR_ID as operatorId,");

        sb.append(getAuthName("x.USER_ID") + " as userName,");
        sb.append(getAuthName("x.OPERATOR_ID") + " as operatorName,");
        sb.append(getUserAddressUserName("x.ADDRESS_ID") + " as consignerName,");
        sb.append(getUserAddress("x.ADDRESS_ID") + " as address,");
        sb.append(getUserAddressPhoneNumber("x.ADDRESS_ID") + " as phone,");

        sb.append("ADDRESS_ID as addressId,");
        sb.append("SN as sn,");
        sb.append("PARTY_SN as partySn,");
        sb.append("STATUS as status,");

        sb.append("CREATE_DATE as createDate,");
        sb.append("UPDATE_DATE as updateDate,");

        sb.append("QUANTITY as quantity");


        return sb.toString();
    }

    public static String getOrderCloudDetailFeild() {
        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");
        sb.append("USER_ID as userId,");


        sb.append(getAuthName("USER_ID") + " as userName,");
        sb.append(goodsName("x.GOODS_ID") + " as goodsName,");
        sb.append(goodsImage("x.GOODS_ID") + " as image,");


        sb.append("STATUS as status,");


        sb.append("CREATE_DATE as createDate,");
        sb.append("UPDATE_DATE as updateDate,");

        sb.append("QUANTITY as quantity,");
        sb.append("PRICE as price");


        return sb.toString();
    }

    public static String getPicture(String key) {
        String path = AuthConstant.getPathUrl();
        String sql = "(SELECT IF(LOCATE('http',URL) > 0,URL,CONCAT('" + path + "',URL)) FROM  pictures as tpictures WHERE ID=x." + key + "  LIMIT 1)";
        return sql;
    }

    public static String getPictureKey(String key) {
        String path = AuthConstant.getPathUrl();
        String sql = "(SELECT IF(LOCATE('http',URL) > 0,URL,CONCAT('" + path + "',URL)) FROM  pictures as tpictures WHERE ID=" + key + "  LIMIT 1)";
        return sql;
    }

    public static String getPictures(String key) {
        String path = AuthConstant.getPathUrl();
        String sql = "(SELECT group_concat(IF(LOCATE('http',URL) > 0,URL,CONCAT('" + path + "',URL))) FROM  pictures as tpictures WHERE FIND_IN_SET(ID,x." + key + ")  LIMIT 1)";
        return sql;
    }
    //SELECT  IF(LOCATE('http',URL) > 0,URL,0) FROM  pictures

    public static String getUsersAgentFeild() {
        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");
        sb.append("NICKNAME as nickName,");
        sb.append("AVATAR as avatar,");
        sb.append("PHONE as phone,");
       // sb.append("(SELECT NAME FROM users_authentication as tusers_authentication WHERE USER_ID=x.ID LIMIT 1) AS name,");
        sb.append("(SELECT " + LangValidUtils.getValid("UG", "IFNULL(NAME_UG,NAME)", "NAME") + " FROM users_authentication as tusers_authentication WHERE USER_ID=x.ID LIMIT 1) AS name,");
       // sb.append(getAuthLangName("x.ID")).append(" AS name,");
        sb.append("(SELECT BALANCE FROM users_wallet as tusers_wallet where user_id=x.ID LIMIT 1) AS balance,");
        sb.append("(SELECT SUM(PRICE) FROM users_wallet_log as tusers_wallet_log where user_id=x.ID AND CREATE_DATE >= DATE_FORMAT(CURDATE() - INTERVAL 1 MONTH, '%Y-%m-01') AND CREATE_DATE < DATE_FORMAT(CURDATE(), '%Y-%m-01') LIMIT 1) AS monthPrice,");
        sb.append("(SELECT NAME FROM users_authentication as tusers_authentication WHERE USER_ID=x.PARENT_USER_ID LIMIT 1) AS parentName,");
        sb.append("(SELECT " + LangValidUtils.getValid("UG", "NAME_UG", "NAME") + " FROM agent as tagent WHERE ID=x.AGENT_ID LIMIT 1) AS agentName");


        return sb.toString();
    }

    public static String getParentUserId(long userId) {
        String sql = "(SELECT ID FROM users as tusers where  PARENT_USER_ID=" + userId + " AND DELETED=0)";
        return sql;
    }

    public static String getAuthName(String key) {
        return "(SELECT NAME FROM  users_authentication as tusers_authentication where  tusers_authentication.USER_ID=" + key + " LIMIT 1)";
    }
    public static String getAuthLangName(String key) {
        if (LangValidUtils.getValid("ug")) {
            return "(SELECT NAME FROM  users_authentication as tusers_authentication where  tusers_authentication.USER_ID=" + key + " LIMIT 1)";
        }else {
            return "(SELECT IFNULL(NAME_UG,NAME) FROM  users_authentication as tusers_authentication where  tusers_authentication.USER_ID=" + key + " LIMIT 1)";
        }
    }

    public static String getGoodsAgentPriceFeild(long goodsId) {
        //   NAME as name,ID as agentId,(SELECT PRICE FROM good_agent_price WHERE AGENT_ID=x.ID LIMIT 1) as price,(SELECT NEW_PRICE FROM good_agent_price WHERE AGENT_ID=x.ID LIMIT 1) as newPrice
        StringBuilder sb = new StringBuilder();
        sb.append("NAME as name,");
        sb.append("ID as agentId,");
        sb.append("(SELECT ID FROM good_agent_price as tgood_agent_price WHERE AGENT_ID=x.ID  AND GOOD_ID=" + goodsId + "   LIMIT 1) as id,");
        sb.append("(SELECT PRICE FROM good_agent_price as tgood_agent_price WHERE AGENT_ID=x.ID  AND GOOD_ID=" + goodsId + "   LIMIT 1) as price,");
        sb.append("(SELECT ACTIVE_PRICE FROM good_agent_price as tgood_agent_price WHERE AGENT_ID=x.ID   AND GOOD_ID=" + goodsId + "   LIMIT 1) as activePrice,");
        sb.append("(SELECT NEW_PRICE FROM good_agent_price as tgood_agent_price WHERE AGENT_ID=x.ID   AND GOOD_ID=" + goodsId + "   LIMIT 1) as newPrice");
        return sb.toString();
    }


    public static String AgentInvitationRelationshipFeild() {
        StringBuilder sb = new StringBuilder();
        sb.append("ID as id,");
        sb.append("RELATION_AGENT_ID as relationAgentId,");
        sb.append(agentName("RELATION_AGENT_ID") + " as relationAgentName,");
        sb.append("AGENT_ID as agentId,");
        sb.append(agentName("AGENT_ID") + " as agentName,");
        sb.append("GOODS_ID as goodsId,");
        sb.append("(SELECT NAME FROM  goods as tgoods  where ID=x.GOODS_ID  LIMIT 1) as goodsName,");
        sb.append("PRICE as price,");
        sb.append("UPGRADE_PRICE as upgradePrice,");
        sb.append("REDUCE_UPGRADE_PRICE as reduceUpgradePrice,");


        sb.append("UPGRADE_AGENT_ID as upgradeAgentId,");
        sb.append("CURRENT_UPGRADE_AGENT_ID as currentUpgradeAgentId,");
        sb.append(agentName("UPGRADE_AGENT_ID") + " as upgradeAgentName,");
        sb.append(agentName("CURRENT_UPGRADE_AGENT_ID") + " as currentUpgradeAgentName,");

        sb.append("STATE as state,");
        sb.append("IS_ACTIVTY as isActivty,");
        sb.append("PARENT_PRICE as parentPrice,");
        sb.append("IS_PRICE as isPrice,");
        sb.append("IS_PARENT as isParent,");
        sb.append("IS_LEVEL as isLevel,");
        sb.append("LEVEL1 as level1,");
        sb.append("LEVEL2 as level2,");
        sb.append("LEVEL3 as level3,");
        sb.append("LEVEL4 as level4,");
        sb.append("CREATE_DATE as createDate,");
        sb.append("UPDATE_DATE as updateDate");


        return sb.toString();
    }


    public static String agentName(String key) {
        String sql = "(SELECT NAME FROM  agent where ID=x." + key + " LIMIT 1)";
        return sql;
    }

    public static String goodsName(String key) {
        String sql = "(SELECT NAME FROM  goods where ID=" + key + " LIMIT 1)";
        return sql;
    }

    public static String goodsImage(String key) {
        String sql = "(SELECT " + getPictureKey("tgoods.IMAGE_ID") + " FROM  goods as tgoods  where ID=" + key + " LIMIT 1)";
        return sql;
    }

    public static String getAuthNameLike(String name) {
        return "(SELECT USER_ID FROM users_authentication as tusers_authentication where name LIKE '%" + name + "%')";
    }

    public static String getCloudGoods(String key) {
        String sql = "(SELECT IFNULL(SUM(QUANTITY),0) FROM  cloud_inventory WHERE GOODS_ID =" + key + " LIMIT 1)";
        return sql;
    }


    public static String getAuthWechatLike(String wechat) {
        String sql = "(SELECT USER_ID FROM users_authentication as tusers_authentication where WECHAT LIKE '%" + wechat + "%')";
        return sql;
    }

    public static String getAttrKeyValue(String attrKey, String value) {
        String sql = "(select NAME FROM attribute_value where ATTRIBUTE_ID in (SELECT ID FROM attribute where ISKEY ='" + attrKey + "') and IS_VALUE=" + value + ")";
        return sql;
    }

    //SELECT USER_ID FROM  notify_users WHERE  FIND_IN_SET(3,TYPE)
    public static String notifyUsers(String key, Object param) {
        String sql = "(SELECT USER_ID FROM  notify_users WHERE  FIND_IN_SET(" + param + "," + key + "))";
        return sql;
    }

    public static String getUserAvatar(String key) {
        String sql = "(SELECT AVATAR FROM users as tusers where  ID=" + key + " LIMIT 1)";
        return sql;
    }

    public static String getUserPhone(String key) {
        String sql = "(SELECT PHONE FROM users as tusers where  ID=" + key + " LIMIT 1)";
        return sql;
    }

    public static String getUserAddress(String key) {
        String sql = "(SELECT concat_ws(' ',ADDRESS,ADDRESS_INFO) FROM  users_address as tusers_address where ID=" + key + "   LIMIT 1)";
        return sql;
    }

    public static String getUserAddressPhoneNumber(String key) {
        String sql = "(SELECT PHONE_NUMBER FROM  users_address as tusers_address where ID=" + key + "   LIMIT 1)";
        return sql;
    }

    public static String getUserAddressUserName(String key) {
        String sql = "(SELECT NAME FROM  users_address as tusers_address where ID=" + key + "   LIMIT 1)";
        return sql;
    }


    public static String getOtherTableColmuns(String tableName, String felid, String keyFelid) {
        String sql = "(SELECT " + felid + " FROM " + tableName + " where " + keyFelid + " LIMIT 1)";
        return sql;
    }

    public static String getFinanceStatastica() {
        String sql = "sum(price) as price,DATE_FORMAT(CREATE_DATE,'%Y') as y,DATE_FORMAT(CREATE_DATE,'%Y-%m') as ym,DATE_FORMAT(CREATE_DATE,'%m') as name ";
        return sql;
    }

    public static String getLoginLogStatastica() {
        return "date_format(CREATE_DATE,'%Y-%m-%d') as ymd,date_format(CREATE_DATE,'%Y-%m') as ym,date_format(CREATE_DATE,'%d') as name,COUNT(*) as count ";
    }

    public static String getGoodsOrderDetailStatastica() {
        return " date_format(CREATE_DATE,'%Y-%m-%d') as ymd,date_format(CREATE_DATE,'%Y-%m') as ym,(SELECT NAME FROM  goods as tgoods WHERE tgoods.ID=x.GOODS_ID LIMIT  1) as name,COUNT(*) as count ";
    }


    public static String getGoodsOrderCloudNewListFeild(long agentId) {
        StringBuilder sb = new StringBuilder();


        sb.append("ID as goodsId,");

        if (LangValidUtils.getValid("ug")) {
            sb.append("NAME_UG as name,");

        } else {
            sb.append("NAME as name,");
        }
        if (agentId > 0) {
            //   sb.append("(SELECT NEW_PRICE FROM `good_agent_price` WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1) as price ,");
            sb.append("(SELECT NEW_PRICE PRICE FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1) as paymentAmount ,");
            sb.append("(SELECT NEW_PRICE PRICE FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1) as paymentAmountL ,");
            sb.append("(SELECT NEW_PRICE PRICE FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1) as price ,");

        }
        sb.append(getPicture("IMAGE_ID") + " as image,");
        sb.append("MARKET_PRICE as totalAmount,");
        sb.append("MARKET_PRICE as totalAmountL,");
        sb.append("MARKET_PRICE-(SELECT NEW_PRICE PRICE FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1)  as discountAmount,");
        sb.append("MARKET_PRICE-(SELECT NEW_PRICE PRICE FROM `good_agent_price` as tgood_agent_price WHERE (`GOOD_ID` =x.ID  AND `AGENT_ID` = " + agentId + ")  LIMIT 1)  as discountAmountL,");
        sb.append("BRAND_ID as brandId,");
        sb.append("CATEGORY_ID as categoryId");

/*        sb.append("MEASURE as measure");
        sb.append("PERMIT as permit");
        sb.append("WEIGHT as weight");
        sb.append("LINKS as links");
        sb.append("PUBLISH_TIME as publishTime");ams
        sb.append("GOOD_NUMBER as goodNumber");
        sb.append("INVENTORY as inventory");
        sb.append("SIZE as size");
        sb.append("COLORS as colors");
        sb.append("MARKET_PRICE as marketPrice");
        sb.append("RETAIL_PRICE as retailPrice");
        sb.append("IMAGE_ID as imageId");
        sb.append("IMAGE_IDS as imageIds");
        sb.append("VIDEO_ID as videoId");
        sb.append("CREATE_DATE as createDate");
        sb.append("UPDATE_DATE as updateDate");*/
        return sb.toString();
    }
}
